<% layout('/layouts/default.html', {title: '任务部署信息表(主)管理', libs: ['validate','fileupload','dataGrid']}){ %>
<style>
	.lhTime .select2-container{
		width: 60% !important;
		margin-left: 10px;
		margin-right: 10px;
	}
	#table2 tr{
		padding-bottom: 10px;
		display: block;
	}
	.addku{
		position: absolute;
		width: 30px;
		border: 1px solid #d3d4d6;
		text-align: center;
		height: 30px;
		line-height: 30px;
		border-radius: 4px;
		margin-left: 5px;
	}

    .hideUnit{
        display: none !important;
    }

    #taskLeaderOrgDiv{
        display: none !important;
    }

    .form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
        background-color: #FFFFFF;
    }
    .addku1{
        width: 76%;
        height: 50px;
        line-height: 50px;
        border-radius: 5px;
position: absolute;
        text-align: center;
        background-color: #1890ff;
        color: #eeeeee;
    }
    .addku1:hover{
        color: #eeeeee;
        cursor: pointer;
    }
    .dbd{
padding: 10px;
        border-bottom: 1px solid gray;
        border-right: 1px solid gray;
        border-left: 1px solid gray;
        margin: auto 10px;
    }
    .dbd:nth-child(1){
        padding: 10px;
        border-bottom: 1px solid gray;
        border-top: 1px solid gray;
    }

    .xbd{
margin-left: 10px;
    }
</style>
<div class="main-content">
	<div class="box box-main">

		<#form:form id="inputForm" model="${dcSupTaskInfo}" action="${ctx}/taskdeploy/dcSupTaskInfo/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								</label>
							<div class="col-sm-8">
								<#form:hidden path="isNewRecord"/>
								<#form:hidden path="normalFlag"/>
								<#form:hidden path="id" maxlength="64" readonly="${!dcSupTaskInfo.isNewRecord}" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('任务年度')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="taskYear" items="${yearList}" blankOption="true" data-placeholder="请选择" itemLabel="yearLabel" itemValue="yearValue" class="form-control width-120 required"
								defaultValue="${currentYear}"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('任务类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8" style="padding-right: 50px;position: relative">
								<#form:select path="taskTypeCode" items="${dicts}" blankOption="true" data-placeholder="请选择任务类型" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-120 required" />
								<#form:hidden path="taskTypeName"/>
								<#form:hidden path="taskStatus"/>
                                <% if(hasRole('SUPLEADER') || @UserUtils.getUser().getUserCode() == 'system'){ %>
                                <a onclick="addTab()" class="addku" style="position: absolute"><i class="fa fa-plus"> </i></a>
                                <% } %>
							</div>
<!--							<div class="col-sm-1" style="border: blue;">-->
<!--								<a onclick="addTab()"><i class="fa fa-plus"> </i></a>-->
<!--							</div>-->
						</div>
					</div>
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('任务标题')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="taskTitle" rows="2" class="form-control required" autocomplete="off" placeholder="任务标题，限制200字以内" maxlength="200"/>
							</div>
						</div>
					</div>
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('任务内容')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="taskContent" rows="5" placeholder="任务内容，限制1000字以内" class="form-control required" style="white-space: pre-line;" maxlength="1000"/>
							</div>
						</div>
					</div>
					<div class="col-xs-12">

						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('起止时间')}：<i
									class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<div class="form-inline" style="padding-left: 0px !important;margin: 0px !important;">
									<#form:input path="taskStartTime" readonly="true" maxlength="20" class="form-control laydate required"
									dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm" style="width:245px" placeholder="开始时间" data-done="taskTimeChange()"/>
									至
									<#form:input path="taskEndTime" readonly="true" maxlength="20" class="form-control laydate required dateCheck"
									dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm" style="width:245px" placeholder="结束时间"/>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('督办要求')}：<i class="fa icon-question hide"></i></label>
							<!--<div class="col-sm-8">
								<#form:hidden path="taskRequireName" />
								<#form:select path="taskRequireCode" dictType="dc_task_require" blankOption="false"
								class="form-control required" />
							</div>-->
							<div class="col-sm-10">
								<#form:textarea path="taskRequireName" rows="3" class="form-control" autocomplete="off" maxlength="1000" placeholder="督办要求，限制1000字以内" />
							</div>
						</div>
					</div>

					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('牵头责任单位')}：<i class="fa icon-question hide"></i></label>
							</label>
							<div class="col-sm-10">
                                <#form:textarea path="taskLeaderOrgBase" rows="5" class="form-control required" autocomplete="off" maxlength="1000" readonly="true" placeholder="请选择牵头责任单位" />
                                <#form:treeselect   title="${text('牵头责任单位')}" allowClear='true'
                                path="taskLeaderOrg" labelName="taskLeaderOrgName" labelValue="${officeName!}" labelPath="taskLeaderOrgName"
                                url="${ctx}/sys/office/treeUnitData"
                                class="hideUnit" isReturnValue="false" allowClear="true" canSelectRoot="true" canSelectParent="true"
                                returnFullName="false" checkbox="true" chkboxType="{'Y':'','N':''}"
                                callbackFuncName='treeselectCallback'
                                placeholder="请选择牵头责任单位"/>
							</div>
						</div>
					</div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-2" title="">
                                <span class="required hide">*</span><i class="fa icon-question hide"></i></label>
                            <!--<div class="col-sm-8">
                                <#form:hidden path="taskRequireName" />
                                <#form:select path="taskRequireCode" dictType="dc_task_require" blankOption="false"
                                class="form-control required" />
                            </div>-->
                            <div class="col-sm-10">

                                    <a onclick="fixGroup()"  class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee" >维护常用组</a>


                                    <a onclick="importGroup()"  class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee" >导入常用组</a>

                            </div>
                        </div>
                    </div>
					<% if(dcSupTaskInfo.normalFlag == '2'){ %>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('协同单位')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:treeselect  title="${text('协同单位')}"
								path="taskCoopOrg" labelName="taskCoopOrgName" labelValue="${officeName!}" labelPath="taskCoopOrgName"
								url="${ctx}/sys/office/treeUnitData" type="text"
								class="" isReturnValue="false" allowClear="true" canSelectRoot="true" canSelectParent="true"
								returnFullName="false" checkbox="true" chkboxType="{'Y':'','N':''}"
								placeholder="请选择协同单位"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6" >
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> 督办人：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="taskSupUser" items="${taskSupUser!}" blankOption="true" data-placeholder="请选择督办人" itemLabel="userName" itemValue="userCode" class="form-control width-120 "/>
								<#form:hidden path="taskSupUserName"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('督办科室')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select id="taskSupOrg" path="taskSupOrg" dictType="dc_task_department"  blankOption="true" data-placeholder="请选择督办科室"  class="form-control width-120" />
								<#form:hidden path="taskSupOrgName" />
							</div>
						</div>
					</div>
					<% } %>
					<div class="col-xs-6" >
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 牵头领导：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">

								<#form:select path="taskLeader" items="${userList!}" blankOption="true" data-placeholder="请选择牵头领导" itemLabel="userName" itemValue="userCode" class="form-control  " multiple="true"/>
								<#form:hidden path="taskLeaderName"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
					<!--	<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('牵头责任单位')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:treeselect  title="${text('牵头责任单位')}" boxWidth='900' boxHeight='600' allowClear='true'
								path="taskLeaderOrg" labelName="taskLeaderOrgName" labelValue="${officeName!}" labelPath="taskLeaderOrgName"
								url="${ctx}/sys/office/treeUnitData" type="text"
								class="required" isReturnValue="false" allowClear="true" canSelectRoot="true" canSelectParent="true"
								returnFullName="false" checkbox="true" chkboxType="{'Y':'','N':''}"
								placeholder="请选择牵头责任单位"/>

								<#form:listselect id="explain" title="用户选择"
                                        url="${ctx}/sys/office/customizedUnitSelect" allowClear="false" checkbox="true" chkboxType="{'Y':'','N':''}" canSelectRoot="true" canSelectParent="true"
                                        labelPath="transferOrgName" path="transferOrgCode" class="required"
                                        checkbox="false" itemCode="userCode" itemName="userName"/>

                                    </div>
                                </div> -->
                            </div>
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-sm-4" title="">
                                        <span class="required hide">*</span> ${text('联系人')}：<i class="fa icon-question hide"></i></label>
                                    <div class="col-sm-8">
                                        <#form:input path="contactName" maxlength="64" value="${dcSupTaskInfo.contactName}" class="form-control" placeholder="联系人"/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-sm-4" title="">
                                        <span class="required hide">*</span> ${text('联系电话')}：<i class="fa icon-question hide"></i></label>
                                    <div class="col-sm-8">
                                        <#form:input path="contactPhone" maxlength="64" value="${dcSupTaskInfo.contactPhone}" class="form-control" placeholder="联系电话"/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-6" id="bihuan">
                                <div class="form-group">
                                    <label class="control-label col-sm-4" title="">
                                        <span class="required hide">*</span> ${text('排序编号')}：<i class="fa icon-question hide"></i></label>
                                    <div class="col-sm-8">
                                        <#form:input  path="sortNum"  maxlength="10" min="1" class="form-control digits" placeholder="排序编号" />
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-sm-4" title="">
                                        <span class="required ">*</span>${text('反馈时间要求')}：<i
                                            class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <#form:select path="feedbackWay" blankOption="true" data-placeholder="请选择反馈时间要求" dictType="dc_feedback_circle_type"  onchange="feedbackCircle()" class="form-control required" defaultValue="4"/>
                                        </div>
                                </div>
                            </div>
                            <div class="col-xs-6" >
                                <div class="form-group" id="feedbackRateShow">
                                    <label class="control-label col-sm-4" title="">
                                        <span class="required hide">*</span><text id ="yearMonth"></text><i class="fa icon-question hide"></i></label>
                                    <div class="col-sm-8 " style="display: flex;line-height: 27px;" id="isshow">
                                        <#form:select path="feedbackRate"  maxlength="2" class="form-control" onchange="getMutiFeedBackTimes()"/>
                                    </div>
                                </div>
                            </div>

                            <div class="row multipleFeedback">
                                <div class="col-xs-12">
                                    <div class="form-group">
                                        <label class="control-label col-sm-2">
                                            <span class="required hide">*</span> </label>
                                        <div class="col-sm-10">
                                            <table id="scheBusiTaskFeedbackDataGrid"></table>
                                            <a href="#" id="testDataChildDataGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> 增加固定反馈时间</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-sm-4" title="">
                                        <span class="required ">*</span> ${text('督办字号')}：<i class="fa icon-question hide"></i></label>
                                    <div class="col-sm-8">
                                        <div style="width: 60%;float:left;">
                                            <#form:select path="msgNum" dictType="${msgType}" onchange ="changeOne()" blankOption="false" class="form-control"/>
                                            <#form:hidden id="msgType" value="${msgType}"/>
                                        </div>
                                        <div style="width: 40%;float:left;padding-left: 2px;">
                                            <#form:input path="msgNum2" maxlength="100" value="${dcSupTaskInfo.messageNumber}" placeholder="督办字号"  maxlength="10" min="1" class="form-control digits required"/>
                                            <#form:hidden path="messageNumber"/>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-sm-4" title="">
                                        <span class="required hide">*</span> ${text('是否生成督办单')}：<i class="fa icon-question hide"></i></label>
                                    <div class="col-sm-8">
                                        <#form:radio path="formFlag" dictType="sys_yes_no" class="form-control" defaultValue="0"/>
<!--                                        <button type="button" class="btn btn-sm btn-primary" style="font-size: 10px;" id="download"><i class="glyphicon glyphicon-save"></i> ${text('督办单下载')}</button>-->
                                        <label class="control-label" id="levelColor">
                                            <span class="required hide">*</span> ${text('督办单等级')}：<i class="fa icon-question hide"></i>
                                            <#form:radio path="remarks4"  dictType="dc_oversee_the_single_color" class="form-control" defaultValue="1"/>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-sm-4" title="">
                                        <span class="required hide">*</span> ${text('反馈附件必填')}：<i class="fa icon-question hide"></i></label>
                                    <div class="col-sm-6">
                                        <#form:radio path="attachmentFlag" dictType="dc_feedback_file" class="form-control" defaultValue="0"/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-6" id="auditDiv">
                                <div class="form-group">
                                    <label class="control-label col-sm-4" title="">
                                        <span class="required hide">*</span> 审核人：<i class="fa icon-question hide"></i></label>
                                    <div class="col-sm-8" id="auditUser">
                                        <#form:listselect id="auditor2" title="审核人"
                                        url="${ctx}/sys/empUser/customizedUserSelect" allowClear="false"
                                        labelPath="auditorName" path="auditorCode"
                                        checkbox="false" itemCode="userCode" itemName="userName"
                                        placeholder="请选择审核人"/>
                                    </div>

                                    <div class="col-sm-8" id="auditusers">
                                        <#form:select path="auditorCode" items="${auditorUserList!}"  blankOption="true" data-placeholder="请选择审核人" itemLabel="userName" itemValue="userCode" class="form-control width-120 required" />
                                        <#form:hidden path="auditorName" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12" id="auditContentDiv" style="display: none">
                                <div class="form-group">
                                    <label class="control-label col-sm-2" title="">
                                        <span class="required hide">*</span> ${text('审核意见')}：<i class="fa icon-question hide"></i></label>
                                    <!--<div class="col-sm-8">
                                        <#form:hidden path="taskRequireName" />
                                        <#form:select path="taskRequireCode" dictType="dc_task_require" blankOption="false"
                                        class="form-control required" />
                                    </div>-->
                                    <div class="col-sm-10">
                                        <#form:textarea id="auditContent" rows="3" class="form-control" autocomplete="off" maxlength="1000" value="${auditContent!}" readonly="true"/>
                                    </div>
                                </div>
                            </div>

                            <div class="col-xs-12">
                                <div class="form-group">
                                    <label class="control-label col-sm-2">
                                        <span class="required hide">*</span> ${text('附件上传')}：</label>
                                    <div class="col-sm-10">
                                        <#form:fileupload id="uploadFile" bizKey="${dcSupTaskInfo.id}" bizType="dcSupTaskInfo_file"
                                            uploadType="all" class="" readonly="false" preview="true" maxUploadNum="10"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="box-footer">
                        <div class="row">
                            <div class="col-sm-offset-2 col-sm-10">
                                <% if (hasPermi('taskdeploy:dcSupTaskInfo:edit')){ %>
                                <% if(dcSupTaskInfo.taskStatus != '' && dcSupTaskInfo.taskStatus != '2'){ %>
                                    <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit" onclick="changeStatus(2);"><i class="fa fa-check"></i> ${text('立即发布')}</button>&nbsp;
                                <% } %>
                                <% if(dcSupTaskInfo.id == '' || dcSupTaskInfo.id == null||dcSupTaskInfo.taskStatus=='1'){ %>
                                <button type="submit" class="btn btn-sm btn-default" id="btnSubmit2" onclick="changeStatus(1);"><i class="fa fa-save"></i> ${text('存为草稿')}</button>&nbsp;
                                <% } %>
                                <% } %>
                                <button type="button" class="btn btn-sm btn-default btnList" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
                            </div>
                        </div>
                    </div>
                </#form:form>
            </div>
        </div>
        <% } %>
        <script>
            var status  = '${dcSupTaskInfo.taskStatus!}'
            if(status=="3" || status=="4" ||status=="5" ||status=="6" ){
                $("#auditContentDiv").show()
            }
            var INIT_DATA=true;
            var normalFlag =${dcSupTaskInfo.normalFlag};
            if(normalFlag=='2'){
                $("#taskSupUser").addClass("required")
                $("#taskSupOrg").addClass("required")
            }

     if ($("#taskStartTime").val()==''){
         $("#taskStartTime").val("${date(),'yyyy-MM-dd 00:00'}")
         laydate.render({
             elem: '#taskEndTime'
             ,type: 'datetime'
             ,format: 'yyyy-MM-dd HH:mm'
             ,done: function(value, date){
                 if(value.substr(11,value.length)=='00:00'){
                     $('#taskEndTime').val(	value.substr(0,11)+"23:59")
                 }
                 taskTimeChange();
             }
         });
     }else{
         $("#taskStartTime").val()
     }





            //动态添加行
            //打开新的标签
            /*切换反馈方式同步切换反馈频次数据*/
            var weekData = [{ id: 1, text: '周一' }, { id: 2, text: '周二' }, { id: 3, text: '周三' }, { id: 4, text: '周四' }, { id: 5, text: '周五' }, { id: 6, text: '周六' }, { id: 7, text: '周日' }];
            var monthData = [{ id: 1, text: '1' }, { id: 2, text: '2' }, { id: 3, text: '3' }, { id: 4, text: '4' },
                { id: 5, text: '5' }, { id: 6, text: '6' }, { id: 7, text: '7' }, { id: 8, text: '8' }, { id: 9, text: '9' },
                { id: 10, text: '10' }, { id: 11, text: '11' }, { id: 12, text: '12' }, { id: 13, text: '13' }, { id: 14, text: '14' },
                { id: 15, text: '15' }, { id: 16, text: '16' }, { id: 17, text: '17' }, { id: 18, text: '18' }, { id: 19, text: '19' },
                { id: 20, text: '20' }, { id: 21, text: '21' }, { id: 22, text: '22' }, { id:23, text: '23' }, { id: 24, text: '24' },
                { id: 25, text: '25' }, { id: 26, text: '26' }, { id: 27, text: '27' }, { id:28, text: '28' },{ id:29, text: '29' },{ id:30, text: '30' },{ id:31, text: '31' }];
            $(function () {
                window.location.hash="#inputForm";
                //根据msgtype判断  审核人事下拉选框选择 还是选择弹窗选择
                var msgType=$("#msgType").val()
                if(msgType=="dc_num_secret"){
                   $("#auditUser").hide();
                   $("#auditor2Name").attr("disabled",true)
                    $("#auditor2Code").attr("disabled",true)
                   $("#auditusers").show();
                }else {
                    $("#auditUser").show();
                    $("#auditusers").hide();
                    $("#auditorCode").attr("disabled",true)
                    $("#auditorName").attr("disabled",true)
                }
                feedbackCircle();
                INIT_DATA = false;
            })

            function addTab(type) {
                js.addTabPage(null, "任务类型管理", "${ctx}/dict/dcSupTaskInfoDict" , true);
            }

            $(function (){
                if($('#formFlag input:radio:checked').val()=='0' || $('#formFlag input:radio:checked').val()== null){
                    $('#levelColor').hide();
                }
            })

            $('#formFlag').on('ifChecked', function(){
                if($('#formFlag input:radio:checked').val()=='1' && normalFlag == '1') {
                    $('#levelColor').show();
                }else{
                    $('#levelColor').hide();
                }

            });

            $("#download").click(function (){
                var form= $('#inputForm');
                $("#messageNumber").val($("#messageNumber").val());
                $("#taskEndTime").val($("#taskEndTime").val());
                $("#taskTypeCode").val($("#taskTypeCode").select2('val'));
                $("#remarks4").val("2");
                js.ajaxSubmitForm(form,{
                    url:"${ctx}/taskdeploy/dcSupTaskInfo/downLoadOverseeTheSingle",
                    downloadFile:true
                })
            })
            //根据多次反馈，反馈频次获取后台所有反馈时间段
            var feedbackListLength =${toJson(dcSupTaskInfo.dcSupTaskInfoAddList)};
            function feedbackCircle(){
                if ($("#feedbackWay").val()=='4'){
                    $("#feedbackRateShow").css("display","none");
                    taskTimeChange();
                }
                else if($("#feedbackWay").val()=='3'){
                    $("#feedbackRate").select2('destroy').empty();
                    $("#feedbackRate").select2({data: weekData,placeholder:'请选择',allowClear:true})
                    $("#yearMonth").text('每周：');
                    $("#feedbackRateShow").css("display","block");
                }else if($("#feedbackWay").val()=='2'){
                    $("#feedbackRate").select2('destroy').empty();
                    $("#feedbackRate").select2({data: monthData,placeholder:'请选择',allowClear:true})
                    $("#yearMonth").text('每月：');
                    $("#feedbackRateShow").css("display","block");
                }else if($("#feedbackWay").val()=='1'){
                    $("#feedbackRate").select2('destroy').empty();
                    $("#feedbackRate").select2({data: monthData,placeholder:'请选择',allowClear:true})
                    $("#yearMonth").text('每季度首月：');
                    $("#feedbackRateShow").css("display","block");
                }else{
                    if(feedbackListLength.length==0){
                        $('#scheBusiTaskFeedbackDataGrid').dataGrid('setParam', {
                            data:[]
                        }, true).dataGrid('reloadGrid');
                    }
                    $("#feedbackRateShow").css("display","none");
                }
                $("#feedbackRate").val([${dcSupTaskInfo.feedbackRate}]).trigger("change")
            }
            //根据多次反馈，反馈频次获取后台所有反馈时间段
            function getMutiFeedBackTimes(){
                if($("#taskStartTime").val()!=null&&$("#taskStartTime").val()!=null&&$("#feedbackWay").val()!=null&&$("#feedbackRate").val()!=null&&feedbackListLength.length==0){
                    $.post("${ctx}/taskdeploy/dcSupTaskInfo/getMutiFeedBackTimes",{taskStartTime:$("#taskStartTime").val(),taskEndTime:$("#taskEndTime").val(),feedbackWay:$("#feedbackWay").val(),feedbackRate:$("#feedbackRate").val()},function (data){
                        if(data.result == Global.TRUE){
                            $('#scheBusiTaskFeedbackDataGrid').dataGrid('setParam', {
                                data:data.data
                            }, true).dataGrid('reloadGrid');
                        }else{
                            js.showMessage(data.message);
                        }
                    });
                };
                if(feedbackListLength.length>0){
                    feedbackListLength=[]
                }
            }
        </script>
        <script>
            function changeStatus(status) {
                if(status==2){
                    $("#taskStatus").val('2')
                }
                if(status==1){
                    $("#taskStatus").val('1')
                }
                $("#messageNumber").val($("#msgNum").find("option:selected").text()+	$("#msgNum2").val());
                $("#inputForm").validate({
                    submitHandler: function (form) {
                        $("#taskTypeName").val($("#taskTypeCode").find("option:selected").text());
                        // $("#taskRequireName").val($("#taskRequireCode").find("option:selected").text());

                         $("#taskSupOrgName").val($("#taskSupOrg").find("option:selected").text());
                        $("#taskSupUserName").val($("#taskSupUser").find("option:selected").text());
                        $("#auditorName").val($("#auditorCode").find("option:selected").text());
                        const selectedValueArr = []
                        for (let i = 0; i < $("#taskLeader").select2("data").length; i++) {
                            // 如果该option被选中，则将它的value存入数组

                                selectedValueArr.push($("#taskLeader").select2("data")[i].text)

                        }
                        // 如果后端需要字符串形式，比如逗号分隔
                        const selectedValueStr = selectedValueArr.join(',')
                        $("#taskLeaderName").val(selectedValueStr);
                        var dd = $("#scheBusiTaskFeedbackDataGrid").dataGrid('getRowData');
                        if(dd.length==0){
                            js.showMessage("反馈开始结束时间不可为空")
                            return;
                        }

                        js.ajaxSubmitForm($(form), function (data) {
                            js.showMessage(data.message);
                            if (data.result == Global.TRUE) {
                                js.closeCurrentTabPage(function (contentWindow) {
                                    contentWindow.page();
                                });
                            }
                        }, "json");
                    }
                });
            }



        //初始化多次反馈表DataGrid对象
        $("#scheBusiTaskFeedbackDataGrid").dataGrid({
            data:${toJson(dcSupTaskInfo.dcSupTaskInfoAddList)} ,
            datatype: "local", // 设置本地数据
            autoGridHeight: function(){return 'auto'}, // 设置自动高度
            // 设置数据表格列
            columnModel: [
                {header:'主键', name:'id', editable:true, hidden:true},
                {header:'${text("任务表主键")}', name:'taskId', editable:true, hidden:true},
                {header:'${text("反馈开始日期")}', name:'feedbackStartTime', width:150,
                    formatter:'date', formatoptions:{srcformat:'Y-m-d H:i',newformat:'Y-m-d H:i'},
                    editable:true, edittype:'text',align:"center", editoptions:{'class':'form-control laydate required', 'readonly':'true',
                        dataInit: function(element){
                            laydate.render({elem:element, type:'datetime', format:'yyyy-MM-dd HH:mm'});
                        }
                }},
                {header:'${text("反馈结束日期")}', name:'feedbackEndTime', width:150,
                    formatter:'date', formatoptions:{srcformat:'Y-m-d H:i',newformat:'Y-m-d H:i'},
                    editable:true, edittype:'text', align:"center",editoptions:{'class':'form-control laydate required gridDateCheck', 'readonly':'true',
                        dataInit: function(element){
                            laydate.render({elem:element, type:'datetime', format:'yyyy-MM-dd HH:mm'});
                        }
                    }},
                {header:'${text("操作")}', name:'actions', width:80, align:'center', formatter: function(val, obj, row, act){
                        var actions = [];
                        if (val == 'new'){
                            actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#scheBusiTaskFeedbackDataGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\')});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
                        }else{
                            actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#scheBusiTaskFeedbackDataGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\',null,{display:\'none\'});$(\'#'+obj.rowId+'_status\').val(\''+Global.STATUS_DELETE+'\');});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
                        }
                        return actions.join('');
                    }, editoptions: {defaultValue: 'new'}}
            ],

            // 编辑表格参数
            editGrid: true,				// 是否是编辑表格
            editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
            emptyDataHint: false, 	// 表格内没有数据的时候是否提示 “无数据显示”  v4.1.7
            emptyDataHintContent: '<center>暂无数据</center>', // 没有数据的提示内容
            editGridAddRowBtn: $('#testDataChildDataGridAddRowBtn'),	// 子表增行按钮
            editGridAddRowBtnToHeader: false,	// 子表增行按钮是否显示到表头上
            editGridAddRowInitData: {id: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据

            // 编辑表格的提交数据参数
            editGridInputFormListName: 'dcSupTaskInfoAddList', // 提交的数据列表名
            editGridInputFormListAttrs: 'id,taskId,feedbackStartTime,feedbackEndTime', // 提交数据列表的属性字段

            // 加载成功后执行事件
            ajaxSuccess: function(data){

            }
        });


            $("#msgNum2").val(`${dcSupTaskInfo.messageNumber}`)
        </script>

        <script>
            function taskTimeChange(){
                if (INIT_DATA && feedbackListLength.length !=0){
                    return;
                }
                let start=$("#taskStartTime").val();
                let end=$("#taskEndTime").val();
                let type=$("#feedbackWay").val();
                if (type=='4'&&start!=''&&end != '' ){
                    $("#scheBusiTaskFeedbackDataGrid").jqGrid("clearGridData");
                    $('#scheBusiTaskFeedbackDataGrid').jqGrid('addRow', { position: 'last',
                        addRowParams: {keys: false, focusField: true},
                        initdata: {id: '',feedbackStartTime:start,feedbackEndTime:end, status: Global.STATUS_NORMAL}
                    });
                }
            }
       </script>


<script>
    $("#taskLeaderOrgBase").click(function (){
        $("#taskLeaderOrgName").click()
    })

    function treeselectCallback(id, act, index, layero, nodes){
        if (act == 'clear'){
            $("#taskLeaderOrgBase").val("")
            return;
        }
        if (act=='ok'){
        let texts=""
        for (let i = 0; i <nodes.length; i++) {
            texts+=nodes[i].name+",";
        }
        if (texts.length > 0) {
           texts = texts.substr(0, texts.length - 1);
        }
        $("#taskLeaderOrgBase").val(texts)
        }
    }

    function fixGroup(){
        js.layer.open({
            type: 2,
            title: ['维护常用组', 'font-size:18px; color:orange;'],
            area: ['800px', '500px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/task/dcSupTaskGroup/list",
            btn1: function (index, layero) {
            },
            end:function () {

            }
        });

    }

    function importGroup(){
        var radioHtml='';
        $.ajax({
            url: "${ctx}/task/dcSupTaskGroup/groupList",
            type: "get",
            cache: false,
            async:false,
            success: function(data){
                $.each(data,function(index,item){
                    radioHtml= radioHtml+'<div class="dbd"><input type="radio" name="groupId" value="'+item.id+'"/><span class="xbd">'+item.groupName+'</span></div> '
                })

            }
        });
        //
        // var groupList = '${toJson(groupList)}';
        // var list =  JSON.parse(groupList);
        //

        layer.open({
            type: 1
            ,title: ['导入常用组', 'font-size:18px; color:orange;'] //不显示标题栏
            ,btn: ['确认', '取消']
            ,btnAlign: 'c'
            ,area: '500px;'
            ,moveType: 1 //拖拽模式，0或者1
            ,content: radioHtml

            ,yes: function(layero){

                $.ajax({
                    url: "${ctx}/task/dcSupTaskGroupUnit/radio",
                    type: "post",
                    cache: false,
                    async:false,
                    data: {
                        "groupId":$("[name='groupId']").filter(":checked").val()

            },
                    success: function(data){
                        $("#taskLeaderOrgBase").val(data.unitNames)
                        $("#taskLeaderOrgBaseCode").val(data.unitCodes)
                        $("#taskLeaderOrgCode").val(data.unitCodes)
                        $("#taskLeaderOrgName").val(data.unitNames)

                    }
                });


            }
        });
    }

</script>

<script>
    jQuery.validator.addMethod("dateCheck", function(v1,v2) {
        var date1= $("#taskStartTime").val();
        var startLogTimeDate = new Date(Date.parse(date1.replace(/-/g, "/"))).getTime();
        var date2=  $("#taskEndTime").val();
        var endLogTimeDate = new Date(Date.parse(date2.replace(/-/g, "/"))).getTime();
        if(endLogTimeDate<=startLogTimeDate){
            return false;
        }else{
            return true;
        }
    }, "结束时间应大于开始时间");

    jQuery.validator.addMethod("gridDateCheck", function(v1,v2) {
        let prefixId= $(v2).attr("rowid")
        let statId= prefixId+"_feedbackStartTime";
        let endId= prefixId+"_feedbackEndTime";
        let date1= $("#"+statId).val();
        let startLogTimeDate = new Date(Date.parse(date1.replace(/-/g, "/"))).getTime();
        let date2=  $("#"+endId).val();
        let endLogTimeDate = new Date(Date.parse(date2.replace(/-/g, "/"))).getTime();
        if(endLogTimeDate<=startLogTimeDate){
            return false;
        }else{
            return true;
        }
    }, "结束时间应大于开始时间");
    var msgNum2=$('#msgNum2').val();
    if(msgNum2.length==0){
        changeOne();
    }else {
        $('#msgNum').val(msgNum2.substring(0,msgNum2.indexOf('〕')+1));
        $('#msgNum2').val(msgNum2.substring(msgNum2.indexOf('〕')+1));
    }
    function changeOne() {
            var msgNum = $('#msgNum').val();
          //  msgNum = msgNum.substring(0,msgNum.indexOf('〔'))
            $.ajax({
                type: 'get',
                url: "${ctx}/taskdeploy/dcSupTaskInfo/getMaxMessageNumberByType?msgNum="+msgNum,
                success: function (res) {
                    $('#msgNum2').val(Number(res.data.msgNum2)+1);
                }
            })
    }

    $(function (){
        if("${dcSupTaskInfo.normalFlag}"!=2){
            $('#bihuan').hide();
        }
    })


</script>